package cn.theten52.demo.patterns.design.behavior.observer.base;

import java.util.Observable;
import java.util.Observer;

/**
 * 观察者
 *
 * @author wangjin
 * @date 2021/4/4
 */
public class ObserverB implements Observer {
    /**
     * This method is called whenever the observed object is changed. An
     * application calls an <tt>Observable</tt> object's
     * <code>notifyObservers</code> method to have all the object's
     * observers notified of the change.
     *
     * @param o   the observable object.
     * @param arg an argument passed to the <code>notifyObservers</code>
     */
    @Override
    public void update(Observable o, Object arg) {
        this.data = arg;
        System.out.println("小A接收到了【" + arg + "】消息！");
    }

    private Object data;

    public Object getData() {
        return data;
    }
}
